From: Colin Walters Date: Mon, 14 Aug 2023 18:27:08 +0000 (-0400) Subject: prepare-root: Use declare-and-initialize X-Git-Tag: archive/raspbian/2023.7-3+rpi1~1^2~9^2^2~23^2~2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=bea5d897a810302263779fcd1542310481626368;p=ostree.git prepare-root: Use declare-and-initialize This is our default style. --- diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c index 1e013613..39f8c500 100644 --- a/src/switchroot/ostree-prepare-root.c +++ b/src/switchroot/ostree-prepare-root.c @@ -205,13 +205,11 @@ static GVariant * load_variant (const char *root_mountpoint, const char *digest, const char *extension, const GVariantType *type, GError **error) { - g_autofree char *path = NULL; + g_autofree char *path = g_strdup_printf ("%s/ostree/repo/objects/%.2s/%s.%s", root_mountpoint, + digest, digest + 2, extension); + char *data = NULL; gsize data_size; - - path = g_strdup_printf ("%s/ostree/repo/objects/%.2s/%s.%s", root_mountpoint, digest, digest + 2, - extension); - if (!g_file_get_contents (path, &data, &data_size, error)) return NULL; @@ -224,9 +222,7 @@ load_commit_for_deploy (const char *root_mountpoint, const char *deploy_path, GV { g_autoptr (GError) local_error = NULL; g_autofree char *digest = g_path_get_basename (deploy_path); - char *dot; - - dot = strchr (digest, '.'); + char *dot = strchr (digest, '.'); if (dot != NULL) *dot = 0; @@ -338,10 +334,8 @@ load_composefs_config (GKeyFile *config, GError **error) const char *line = *iter; if (strlen (line) > 0) { - g_autofree guchar *pubkey = NULL; gsize pubkey_size; - - pubkey = g_base64_decode (line, &pubkey_size); + g_autofree guchar *pubkey = g_base64_decode (line, &pubkey_size); ret->pubkeys = g_list_append ( ret->pubkeys, g_bytes_new_take (g_steal_pointer (&pubkey), pubkey_size)); } @@ -360,13 +354,11 @@ main (int argc, char *argv[]) { char srcpath[PATH_MAX]; struct stat stbuf; - - const char *root_arg = NULL; g_autoptr (GError) error = NULL; if (argc < 2) err (EXIT_FAILURE, "usage: ostree-prepare-root SYSROOT"); - root_arg = argv[1]; + const char *root_arg = argv[1]; g_autoptr (GKeyFile) config = load_config (&error); if (!config)